package com.syni.mdd.sjb.common.datatreaure.utils;

import com.syni.mdd.sjb.common.component.utils.common.spring.ApplicationContextHolder;
import com.syni.mdd.sjb.common.component.utils.redis.utils.RedisTemplateUtils;
import com.syni.mdd.sjb.common.datatreaure.constants.Constants;

public class VerificationCodeUtils {

    public static void sendVerificationCode(String phone,Integer codeType){

    }

    public static boolean checkVerificationCode(String phone,String verificationCode,Integer codeType){
        if(ApplicationContextHolder.checkRunProfile(ApplicationContextHolder.RUN_DEV,
                ApplicationContextHolder.RUN_LOCAL,ApplicationContextHolder.RUN_PREO)){
        }
        String key = Constants.REDIS_KEY_VERIFICATION_CODE + codeType + ":" + phone;
        if(RedisTemplateUtils.getRedisTemplate().hasKey(key)){
            String identifyCode = RedisTemplateUtils.getRedisTemplate().opsForValue().get(key).toString();
            if(identifyCode != null && identifyCode.equals(verificationCode)){
                RedisTemplateUtils.delete(key);
                return true;
            }
        }
        return false;
    }
}
